<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入模板引擎库文件 -->
    <script src="/js/template-web.js"></script>
</head>

<body>
    <div id="container"></div>
    <!-- 准备模板 -->
    <script id="tpl" type="text/html">
        <h1>{{username}}{{age}}</h1>
    </script>
    <script>
        //告诉模板引擎将那个数据和那个模板进行拼接
        //1.模板id 2.数据
        //方法的返回值是拼接好的html字符串
        var html = template('tpl', {
            username: 'zhangsan',
            age: 30
        });
        console.log(html);
        document.getElementById('container').innerHTML = html;
    </script>
</body>

</html>